<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
	template="/templates/template-login.xhtml">

	<f:metadata>
		<f:event type="preRenderView" listener="#{login.verificarSessionInvalidate}" />
	</f:metadata>

	<ui:define name="body">
		<p:growl id="msgs" autoUpdate="false" showDetail="true" globalOnly="false" life="#{const.growlTime}" />

		<h:form id="formLogin" prependId="false">

			<p:fieldset legend="&#193;rea Restrita">
				<div align="center">
					<h:panelGrid id="panelCadastro" columns="2" columnClasses="coluna15, coluna80" width="50%">
						<h:outputText styleClass="icoObrigatorio" value="Login:" />
						<p:inputText id="login" value="${login.model.login}" maxlength="20" size="20" />
						<h:outputText styleClass="icoObrigatorio" value="Senha:" />
						<p:password feedback="false" id="senha" value="${login.model.senha}" maxlength="20" size="20" />
					</h:panelGrid>
				</div>
				<br />
				<div align="center">
					<p:commandButton value="Entrar" action="${login.logar}" ajax="false" update="msgs" />
				</div>
				<br />
				<div align="center">
					<p:commandLink id="trocar" styleClass="semLink" update="msgs2" oncomplete="dialogSenha.show()"
						actionListener="#{login.limpar}" value="Trocar Senha" />
					<h:outputText value=" | " styleClass="semLink" />
					<p:commandLink styleClass="semLink" update="msgsemail" oncomplete="emailDialog.show()"
						actionListener="#{login.limpar}" value="Esqueci minha senha" />
				</div>

				<p:dialog header="Esqueci Minha Senha" id="emailDialogId" widgetVar="emailDialog" width="470" closable="true"
					showEffect="slide">
					<p:messages id="msgsemail" showDetail="true" globalOnly="true" autoUpdate="false" />

					<h:panelGrid columns="2" id="panelEMail" columnClasses="coluna30,coluna70" width="100%">
						<h:outputText value="Login" styleClass="icoObrigatorio" />
						<p:inputText id="userNameEmail" value="#{login.userName}" />

						<h:outputText value="Senha Administrador" styleClass="icoObrigatorio" />
						<p:password feedback="false" minLength="6" id="senhaAdm" value="#{login.senhaAdm}" autocomplete="off" />
						<p:message for="senhaAdm" />
					</h:panelGrid>
					<div align="center">
						<p:commandButton value="Enviar" process="emailDialogId" actionListener="#{login.restaurarSenha}"
							update="msgsemail,panelEMail" />
					</div>
				</p:dialog>


				<p:dialog header="Trocar Senha" id="dialogSenhaid" widgetVar="dialogSenha" width="400" closable="true"
					showEffect="slide" hideEffect="slide">
					<p:fieldset id="idTT">
						<p:messages id="msgs2" showDetail="true" globalOnly="true" autoUpdate="false" />

						<h:panelGrid columns="3" id="panelTT" columnClasses="coluna20,coluna20,coluna60" width="100%">

							<h:outputText value="Usuário" styleClass="icoObrigatorio" />
							<p:inputText id="userNameTroca" value="#{login.userName}" />
							<p:message for="userNameTroca" />

							<h:outputText value="Senha Atual" styleClass="icoObrigatorio" />
							<p:password feedback="false" minLength="6" id="senhaAnterior" value="#{login.senhaAnterior}" autocomplete="off" />
							<p:message for="senhaAnterior" />

							<h:outputText value="Nova Senha:" styleClass="icoObrigatorio" />
							<p:password minLength="6" feedback="true" autocomplete="off" value="#{login.senha}" id="senhanova"
								promptLabel="Por favor insira a senha" weakLabel="Fraca" goodLabel="Boa" strongLabel="Forte" />
							<p:message for="senhanova" />

							<h:outputText value="Confirmação:" styleClass="icoObrigatorio" />
							<p:password feedback="false" minLength="6" autocomplete="off" id="senhaconfirma" value="#{login.senha2}"
								promptLabel="Por favor insira a senha" />
							<p:message for="senhaconfirma" />
						</h:panelGrid>
						<div align="center">
							<p:commandButton value="Salvar" process="idTT" actionListener="#{login.saveDadosAlterarSenha}" update="idTT" />
						</div>
						<br />
					</p:fieldset>
				</p:dialog>
			</p:fieldset>
			<div align="center">
				<h:outputText style="color:red;font-size:16px;" value="#{const.timeSessionvalue}"
					rendered="#{login.mostrarMsgInvalidate}" />
			</div>
		</h:form>
	</ui:define>
</ui:composition>